home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / sfu.vbs < prev    next >
Text File  |  2003-08-13  |  5KB  |  182 lines

  1. ' Caption: Upload to SourceForge|
  2. ' Hint: Upload files to SourceForge using SSH|
  3. ' Icon: sfu.ico|
  4. '
  5. '  syn
  6. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  8. '
  9. '  The contents of this file are subject to the Mozilla Public License
  10. '  Version 1.1 (the "License"); you may not use this file except in compliance
  11. '  with the License. You may obtain a copy of the License at
  12. '  http://www.mozilla.org/MPL/
  13. '
  14. '  Software distributed under the License is distributed on an "AS IS" basis,
  15. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. '  the specific language governing rights and limitations under the License.
  17. '
  18. '  The Original Code is sfu.vbs, released Wed, 24 Jul 2002 21:18:45 UTC.
  19. '
  20. '  The Initial Developer of the Original Code is Ascher Stefan.
  21. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22. '  All Rights Reserved.
  23. '
  24. '  Contributor(s): .
  25. '
  26. '  Alternatively, the contents of this file may be used under the terms of the
  27. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  28. '  the provisions of the GPL are applicable instead of those above.
  29. '  If you wish to allow use of your version of this file only under the terms
  30. '  of the GPL and not to allow others to use your version of this file
  31. '  under the MPL, indicate your decision by deleting the provisions above and
  32. '  replace them with the notice and other provisions required by the GPL.
  33. '  If you do not delete the provisions above, a recipient may use your version
  34. '  of this file under either the MPL or the GPL.
  35. '
  36. '  You may retrieve the latest version of this file at the syn home page,
  37. '  located at http://syn.sourceforge.net/
  38. '
  39. ' $Id: sfu.vbs,v 1.10.2.5 2003/08/13 00:38:45 neum Exp $
  40. '
  41.  
  42. ' ScriptEngine=VBScript
  43.  
  44. option explicit
  45.  
  46. '#include <consts>
  47. '#include <cmnfunc>
  48.  
  49. ' Modify this three constants
  50. const user    = "stievie"
  51. const docsdir = "/home/groups/s/sy/syn/htdocs/"
  52. const server  = "@syn.sourceforge.net:"
  53.  
  54. dim list
  55. dim uploadbtn
  56. dim cdir
  57.  
  58. sub AddFilesClick(Sender)
  59.   dim i, j
  60.   with Create("TOpenDialog", Self)
  61.     .Title = "Select Files"
  62.     .Filter = "All Files (*.*)|*.*|Web Files (*.htm,*.html,*.css,*.js,*.pl,*.cgi,*.php,*.txt)|*.htm;*.html;*.css;*.js;*.pl;*.cgi;*.php;*.txt|" & _
  63.     "Pictures (*.png,*.jpg,*.gif)|*.png;*.jpg;*.gif"
  64.     .Options = .Options & ",ofAllowMultiSelect"
  65.     if DirExists(cdir) then
  66.       .InitialDir = cdir
  67.     end if
  68.     if .Execute then
  69.       for j = 0 to .FilesCount - 1
  70.         i = list.Items.Add(.Files(j))
  71.         list.Checked(i) = true
  72.       next
  73.     end if
  74.     .Free
  75.   end with
  76.   uploadbtn.Enabled = list.Items.Count > 0
  77. end sub
  78.  
  79. sub Main(FileName)
  80.   dim form
  81.  
  82.   if Documents.Count > 0 then
  83.     cdir = ExtractFilePath(ActiveDocument.FileName)
  84.     if not CheckSave then
  85.       exit sub
  86.     end if
  87.   end if
  88.  
  89.   form = Create("TForm", Self)
  90.   with form
  91.     .Caption = "Upload Files to SourceForge"
  92.     .Position = "poOwnerFormCenter"
  93.     .BorderStyle = "bsDialog"
  94.     .Height = 280
  95.     .Width = 350
  96.   end with
  97.   list = Create("TCheckListBox", Self)
  98.   with list
  99.     .Parent = form
  100.     .Left = 5
  101.     .Top = 20
  102.     .Height = form.ClientHeight - 100
  103.     .Width = form.ClientWidth - 10
  104.     dim i, j
  105.     for i = 0 to Documents.Count - 1
  106.       if Documents(i).FileName <> "" then
  107.         j = .Items.Add(Documents(i).FileName)
  108.         .Checked(j) = true
  109.       end if
  110.     next
  111.   end with
  112.   with Create("TLabel", Self)
  113.     .Parent = form
  114.     .Caption = "&Select the files to upload:"
  115.     .Top = 5
  116.     .Left = 5
  117.     .FocusControl = list
  118.   end with
  119.   dim subdir
  120.   subdir = Create("TEdit", Self)
  121.   with subdir
  122.     .Parent = form
  123.     .Left = 5
  124.     .Top = list.Top + list.Height + 20
  125.     .Width = form.ClientWidth - 10
  126.   end with
  127.   with Create("TLabel", Self)
  128.     .Parent = form
  129.     .Caption = "&Sub Directory (must exist on the Server):"
  130.     .Top = list.Top + list.Height + 5
  131.     .Left = 5
  132.     .FocusControl = subdir
  133.   end with
  134.   uploadbtn = Create("TButton", Self)
  135.   with uploadbtn
  136.     .Parent = form
  137.     .Caption = "Upload"
  138.     .Default = true
  139.     .Left = form.ClientWidth - (.Width * 2) - 10
  140.     .Top = form.ClientHeight - .Height - 5
  141.     .ModalResult = mrOK
  142.     .Hint = "Upload selected files"
  143.     .Enabled = list.Items.Count > 0
  144.   end with
  145.   with Create("TButton", Self)
  146.     .Parent = form
  147.     .Caption = "Cancel"
  148.     .Cancel = true
  149.     .Left = form.ClientWidth - (.Width) - 5
  150.     .Top = form.ClientHeight - .Height - 5
  151.     .ModalResult = mrCancel
  152.   end with
  153.   with Create("TButton", Self)
  154.     .Parent = form
  155.     .Caption = "&Add File(s)..."
  156.     .Left = 5
  157.     .Top = form.ClientHeight - .Height - 5
  158.     .OnClick = "AddFilesClick"
  159.   end with
  160.  
  161.   if form.ShowModal = mrOK then
  162.     dim files
  163.     for i = 0 to list.Items.Count - 1
  164.       if list.Checked(i) then
  165.         files = files & AddQuotesUnless(ExtractFileName(list.Items(i))) & " "
  166.       end if
  167.     next
  168.     dim pdir
  169.     if files <> "" then
  170.       pdir = CurDir
  171.       CurDir = cdir
  172.       if subdir.Text <> "" then
  173.         docsdir = docsdir & AddSlash(subdir.Text)
  174.       end if
  175.       ' not very exhaustive the documentation to this scp program ;-).
  176.       Execute "scp " & files & user & server & docsdir, _
  177.       1, true  ' Show the window for the password
  178.       CurDir = pdir
  179.     end if
  180.   end if
  181. end sub
  182.